﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CoastalClimbing
{
    public partial class ProgramDetails : System.Web.UI.Page
    {
        private Dictionary<string, ProgramDetailData> DETAILS
        {
            get
            {
                Dictionary<string, ProgramDetailData> details = new Dictionary<string,ProgramDetailData>();
                details.Add("y", new ProgramDetailData() { Description = "Find balance through our weekly yoga classes: Yoga promotes balance, increases core strength, calms your mind, and teaches you how to be in your body.", ImageUrl = "yoga.png", MyPanel = pnlYoga, Title = "Yoga" });
                details.Add("c", new ProgramDetailData() { Description = "Whether you're new to climbing or just interested in improving your skills, we've got programs for you.", ImageUrl = "classes.png", MyPanel = pnlClasses, Title = "Bouldering classes" });
                details.Add("tp", new ProgramDetailData() { Description = "Take your climbing to the next level through one of our dedicated training programs.", ImageUrl = "trainingprograms.png", MyPanel = pnlTraining, Title = "Training programs" });
                details.Add("p", new ProgramDetailData() { Description = "Let Coastal Climbing help you throw a party that your friends are sure to enjoy and remember.", ImageUrl = "parties.png", MyPanel = pnlParties, Title = "Parties" });

                return details;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                ProgramDetailData data = new ProgramDetailData();

                if(Request.QueryString["t"] != null)
                {
                    string qs = Request.QueryString["t"].ToString();

                    if(DETAILS.ContainsKey(qs))
                    {
                        data = DETAILS[qs];

                        data.MyPanel.Visible = true;
                        //litTitle.Text = data.Title;
                        litDescription.Text = data.Description;
                        imgProgram.ImageUrl = string.Format("http://www.coastalclimbing.com/images/{0}", data.ImageUrl);
                    }

                    foreach(var d in DETAILS)
                    {                        
                        if(d.Value.MyPanel != data.MyPanel)
                        {
                            d.Value.MyPanel.Visible = false;
                        }
                    }
                }
            }
        }
    }

    public class ProgramDetailData
    {
        public string ImageUrl;
        public string Description;
        public string Title;
        public Panel MyPanel;
    }
}